package com.example.hehecat.yuejian1.mvp.presenter;

import android.support.annotation.Nullable;
import android.util.Log;

import com.example.hehecat.yuejian1.mvp.contract.UpdateMineContract;
import com.example.hehecat.yuejian1.mvp.model.UpdateMineModel;
import com.example.hehecat.yuejian1.mvp.model.bean.SuccessBean;
import com.example.hehecat.yuejian1.mvp.model.bean.UserBean;


import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import rx.Subscriber;

public class UpdateMinePresenter implements UpdateMineContract.Presenter {
    private UpdateMineContract.Model model;
    private UpdateMineContract.View view;

    public UpdateMinePresenter(UpdateMineContract.View view){
        this.view = view;
        model = new UpdateMineModel();
    }

    @Override
    public void updateMine(int user_id, String nickname, String password, String address, String phone){
        model = new UpdateMineModel();
        model.updatemine(user_id, nickname, password, address, phone, new Callback<SuccessBean>() {
            @Override
            public void onResponse(@Nullable Call<SuccessBean> call, @Nullable Response<SuccessBean> response) {
                Log.d("userid",String.valueOf(response.body().getSuccess()));
                if (response.body().getSuccess() == 1){
                    view.showdata("修改成功");
                }else {
                    view.showdata("修改失败");
                }
            }

            @Override
            public void onFailure(Call<SuccessBean> call, Throwable t) {

            }
        });
    }

}
